package com.zero.manage.web.components.vo;

import com.querydsl.core.types.Projections;
import com.querydsl.core.types.QBean;
import com.zero.manage.web.components.entity.rbac.QSysPowerEntity;
import io.gitee.zerowsh.enums.ToolEnums;
import io.gitee.zerowsh.util.TreeNode;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.Column;

@Getter
@Setter
public class SysPowerVO extends TreeNode {
    /**
     * 类型
     */
    private ToolEnums.PowerTypeEnums type;
    /**
     * 排序
     */
    private Integer sort;

    /**
     * 接口地址
     */
    private String url;

    /**
     * 资源路径,前端路由地址
     */
    private String path;
    /**
     * 是否缓存,前端路由是否缓存
     */
    @Column(name = "cache")
    private ToolEnums.WhetherEnums cache;
    /**
     * 图标
     */
    private String icon;

    public QBean<SysPowerVO> initQBean(QSysPowerEntity qSysPowerEntity) {
        return Projections.bean(SysPowerVO.class,
                qSysPowerEntity.id, qSysPowerEntity.parentId, qSysPowerEntity.parentIds, qSysPowerEntity.name,
                qSysPowerEntity.url, qSysPowerEntity.createTime, qSysPowerEntity.icon, qSysPowerEntity.sort,
                qSysPowerEntity.path, qSysPowerEntity.cache, qSysPowerEntity.remarks, qSysPowerEntity.type);
    }
}
